import type {
  UserAddDTOType,
  UserUpdateDTOType,
  UserSearchDTOType,
  LoginUserType,
  UserLoginVOType,
} from '@/resources/interface/user/UserTypes'
import type { TableColumn } from '@/components/CommonTable.vue'
import { ComponentEnum, type FormItemConfig } from '@/components/CommonDialogForm.vue'

/**
 * 用户表 参数对象
 */
export class UserParams {
  /**
   * 表单参数
   */
  static formColumn: FormItemConfig[] = [
    {
      label: '用户名',
      prop: 'userName',
      type: ComponentEnum.INPUT,
      field: 'userName',
    },
    {
      label: '密码',
      prop: 'password',
      type: ComponentEnum.INPUT,
      field: 'password',
    },
    {
      label: '真实姓名',
      prop: 'realName',
      type: ComponentEnum.INPUT,
      field: 'realName',
    },
    {
      label: '邮箱地址',
      prop: 'email',
      type: ComponentEnum.INPUT,
      field: 'email',
    },
    {
      label: '联系电话',
      prop: 'phone',
      type: ComponentEnum.INPUT,
      field: 'phone',
    },
    {
      label: '角色',
      prop: 'role',
      type: ComponentEnum.SELECT,
      field: 'role',
      attribute: {
        size: 'default',
      },
      options: [
        { label: '学生', value: 0 },
        { label: '老师', value: 1 },
        { label: '管理员', value: 2 },
      ],
    },
  ]
  /**
   * 表格参数
   */
  static tableColumn: TableColumn[] = [
    {
      label: '用户名',
      field: 'userName',
    },
    {
      label: '真实姓名',
      field: 'realName',
    },
    {
      label: '邮箱地址',
      field: 'email',
    },
    {
      label: '联系电话',
      field: 'phone',
    },
    {
      label: '角色',
      field: 'role',
      formatter: (row) => {
        return row.role === 0 ? '学生' : row.role === 1 ? '老师' : '管理员'
      },
    },
    {
      label: '操作',
      field: 'right',
      attribute: {
        fixed: 'right',
        width: '200px',
      },
      template: {
        options: [
          {
            icon: 'edit',
            type: 'primary',
            size: 'small',
            method: 'update',
          },
          {
            icon: 'delete',
            type: 'danger',
            size: 'small',
            method: 'remove',
          },
        ],
      },
    },
  ]
  /**
   * 添加对象
   */
  static addDTO: UserAddDTOType = {
    userName: '',
    password: '',
    realName: '',
    email: '',
    phone: '',
    role: 0,
  }
  /**
   * 修改对象
   */
  static updateDTO: UserUpdateDTOType = {
    id: 0,
    userName: '',
    password: '',
    realName: '',
    email: '',
    phone: '',
    role: 0,
  }
  /**
   * 查询对象
   */
  static searchDTO: UserSearchDTOType = {
    userName: '',
    realName: '',
    role: '',
    page: {
      current: 1,
      size: 20,
    },
  }
  static loginDTO: LoginUserType = {
    password: '',
    userName: '',
  }
  static loginVO: UserLoginVOType = {
    id: 0,
    role: 0,
    userName: '',
    realName: '',
  }
}
